import { _decorator, Component, director, Node, ProgressBar, resources } from 'cc';
import { Index, Page } from './Index';
const { ccclass, property, type } = _decorator;
/**场景枚举 */
export enum Scene {
    SCENE = 'scene'
}

@ccclass('Loding')
export class Loding extends Component {
    //进度条节点
    @type(ProgressBar)
    probar: ProgressBar;

    start(): void {
        resources.preloadScene(String('scenes/').concat(Loding.scene),
            (finished: number, total: number) => {
                this.probar.progress = (finished + total) * 0.2;
            }, (err?: Error | null) => {
                if (err === undefined) {
                    director.loadScene(Loding.scene);
                }
            });
    }
    /**默认加载类上的场景名 */
    static scene: Scene = Scene.SCENE;
    /**打开加载 */
    static loadPage() {
        Index.ShowPage(Page.LODING);
    }
}


